using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;

namespace Oops.Xna.Framework.UI
{
	public struct Size
	{
		public static readonly Size Empty;

		private int width;
		private int height;

		static Size()
		{
			Size.Empty = new Size();
		}

		public Size(Point point)
		{
			this.width = point.X;
			this.height = point.Y;
		}

		public Size(int width, int height)
		{
			this.width = width;
			this.height = height;
		}

		public int Width
		{
			get { return this.width; }
			set { this.width = value; }
		}

		public int Height
		{
			get { return this.height; }
			set { this.height = value; }
		}

		public bool IsEmpty
		{
			get { return this.width == 0 && this.height == 0; }
		}

		public static Size Add(Size size1, Size size2)
		{
			return new Size(size1.Width + size2.Width, size1.Height + size2.Height);
		}

		public static Size Subtract(Size size1, Size size2)
		{
			return new Size(size1.Width - size2.Width, size1.Height - size2.Height);
		}

		public override bool Equals(object obj)
		{
			if (!(obj is Size))
			{
				return false;
			}

			Size size = (Size)obj;
			return size.width == this.width && size.height == this.height;
		}

		public override int GetHashCode()
		{
			return this.width ^ this.height;
		}

		public override string ToString()
		{
			return "{Width=" + this.width.ToString() + ", Height=" + this.height.ToString() + "}";
		}

		public static Size operator +(Size size1, Size size2)
		{
			return Size.Add(size1, size2);
		}

		public static Size operator -(Size size1, Size size2)
		{
			return Subtract(size1, size2);
		}

		public static bool operator ==(Size size1, Size size2)
		{
			return size1.Width == size2.Width && size1.Height == size2.Height;
		}

		public static bool operator !=(Size size1, Size size2)
		{
			return !(size1 == size2);
		}

		public static explicit operator Point(Size size)
		{
			return new Point(size.Width, size.Height);
		}
	}

}